home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / CAVoiceDetect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-26  |  3.4 KB  |  124 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    CAVoiceDetect                                                                */
  4. /*                                                                                                */
  5. /*    File Name:        CAVoiceDetect.c                                                                */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1994-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1994-07-15    Jaakko Railo        Original version                                        */
  15. /*                                                                                                */
  16. /************************************************************************************************/
  17.  
  18. /****************************************** DESCRIPTION ******************************************
  19.  
  20. *************************************************************************************************/
  21.  
  22. /******************************************** HEADERS *******************************************/
  23.  
  24. #ifndef __TELEPHONES__
  25. #include "Telephones.h"
  26. #endif
  27.  
  28. #include "TestModule.h"
  29.  
  30. /****************************************** DEFINITIONS *****************************************/
  31.  
  32. #define    rDisplayVoiceDetectDLOG    10000
  33. #define    kVoiceDetectOnItem            2
  34. #define    kVoiceDetectOffItem            3
  35. #define    kVoiceDetectOn                1
  36. #define    kVoiceDetectOff                0
  37.  
  38. /****************************************** PROTOTYPES ******************************************/
  39.  
  40. short         DisplayVoiceDetect (void);
  41. void         DoTest (CHRSPtr paramPtr);
  42.  
  43. /************************************************************************************************/
  44. /************************************************************************************************/
  45.  
  46.  
  47. pascal short TestModule (CHRSPtr paramPtr)
  48. {
  49.     short    returnValue = noErr;
  50.     
  51.     if (paramPtr->version <= kTestModuleVersion) {
  52.         
  53.         DoTest (paramPtr);
  54.         
  55.     }
  56.     else
  57.         returnValue = kWrongVersion;
  58.         
  59.     return (returnValue);
  60. }
  61.  
  62.  
  63. short DisplayVoiceDetect (void)
  64. {
  65.     short        itemHit;
  66.     DialogPtr    theDialog;
  67.     
  68.     if ((theDialog = GetNewDialog (rDisplayVoiceDetectDLOG, nil, (WindowPtr)(-1L))) != nil) {
  69.         
  70.         ShowWindow (theDialog);
  71.         
  72.         ModalDialog (nil, &itemHit);
  73.         
  74.         DisposeDialog (theDialog);
  75.     }
  76.     else
  77.         itemHit = -1;
  78.     
  79.     return (itemHit);
  80. }
  81.  
  82.  
  83. void DoTest (CHRSPtr paramPtr)
  84. {
  85.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  86.     TELDNHandle    dnHand;
  87.     short        numOfCAs;
  88.     TELCAHandle caHand;
  89.     short        itemHit;
  90.     OSErr        errCode;
  91.     Boolean        voiceDetect;
  92.     
  93.     if ((dnHand = GetDNHandle (paramPtr)) != nil) {
  94.  
  95.         if ((numOfCAs = TELCountCAs (dnHand, telAllCallOrigins)) > 0) {
  96.  
  97.             if ((caHand = GetCAHandle (paramPtr)) != nil) {
  98.                 itemHit = DisplayVoiceDetect ();
  99.                 if ((itemHit == kVoiceDetectOnItem) || (itemHit == kVoiceDetectOffItem)) {
  100.                     
  101.                     voiceDetect = (itemHit == kVoiceDetectOnItem)?kVoiceDetectOn:kVoiceDetectOff;
  102.                     
  103.                     if ((errCode = TELCAVoiceDetect (caHand, voiceDetect)) == noErr)
  104.                         Print (paramPtr, "TELCAVoiceDetect --> VoiceDetect = %s", 
  105.                                 ((voiceDetect==kVoiceDetectOn)?"VoiceDetectOn":"VoiceDetectOff"));
  106.                     else
  107.                         Print (paramPtr, "### TELCAVoiceDetect failed : %d", errCode);
  108.                 }
  109.                 else
  110.                     if (itemHit == -1)
  111.                         Print (paramPtr, "### Unable to get a DLOG resource");
  112.             }
  113.             else
  114.                 Print (paramPtr, "### Unable to retrieve the CA handle");
  115.         }
  116.         else
  117.             Print (paramPtr, "### Number of CAs is %d", numOfCAs);
  118.     }
  119.     else
  120.         Print (paramPtr, "### Unable to retrieve the DN handle");
  121. }
  122.  
  123.  
  124.